home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMIBEST3.ADF / Journal / Journal.DOC < prev    next >
Text File  |  1987-07-22  |  19KB  |  404 lines

  1.  
  2. From:  dpvc@ur-tut.UUCP (Davide P. Cervone) Newsgroups:  comp.sources.amiga
  3. Subject:  Journal and Playback (documentation) Date:  10 Jul 87 18:57:20
  4. GMT Reply-To:  doc@s.cc.purdue.edu (Craig Norborg) Organization:  Purdue
  5. University Computing Center
  6.  
  7.  
  8. Well, when I was working on MonIDCMP, I wanted to provide a real-life
  9. example of how it could be used for something useful (like HARDCOPY was to
  10. MONPROC). I thought, "Wouldn't it be great to be able to record and play
  11. back the events that went on in a window?" You could make "Guided Tour"
  12. demonstrations, or turnkey systems that perform all kinds of mouse and
  13. keyboard activity, or you could record the events that demonstrate a bug
  14. that you have been able to produce and send the recorded events to
  15. Commodore as documentation of the bug.
  16.  
  17. But MonIDCMP doesn't have the power to accomplish this:  it can trick a
  18. window into thinking that things have happened, but gadgets would not
  19. REALLY be pressed, and windows would not REALY be resized.  To do it right
  20. you have to go directly to the Input Device and look at the events that are
  21. being passed to Intuition.
  22.  
  23. I set out to do this.  What I came up with was JOURNAL and PLAYBACK.  To
  24. see what they do and what they are good for, read the following document,
  25. which describes in detail how to use JOURNAL and PLAYBACK.  
  26.  
  27. With a little more work, these could become important documentation tools
  28. for any Amiga software company.  I am willing to do that additional work,
  29. but only if there is sufficient interest.  If you want to see the
  30. enhancements I discuss below (or any of your own design), please contact me
  31. and let me know.  I did this mainly as an exercise, but think it would be
  32. valuable to continue work on it, but not if I'm the only one who will use
  33. it.
  34.  
  35. I hope you find these little programs interesting.  I think they're kind of
  36. spooky myself.  I'm not sure I like it when my computer types things for me
  37. without my pressing the keys...
  38.  
  39. Davide P. Cervone
  40. dpvc@tut.cc.rochester.EDU
  41. dpvc@ur-tut.UUCP
  42. DPVC@UORDBV.BITNET
  43.  
  44.  
  45.  
  46. JOURNAL is a program that records a sequence of mouse and keyboard events
  47. as they occur and stores them in a file.  The file can be played back via
  48. the program PLAYBACK, thus causing the same sequence of events to occur
  49. again.  This is useful for creating demonstrations of programs (much like
  50. the "Guided Tours" on the Macintosh computer).
  51.  
  52. It also is useful for documenting repeatable bugs:  rather than trying to
  53. describe to Commodore-Amiga Technical Support (or some third-party vender)
  54. what you did that revealed the bug, you could record the actions with
  55. JOURNAL, and send them the output file instead.  Finally, you can use
  56. JOURNAL to set up turnkey demo-disks for conferences and computer shows
  57. that will run unattended while you talk to customers.
  58.  
  59. It's even possible for PLAYBACK to restart itself when it comes to the end
  60. of the file.  In a future version, there will be a journal editor that
  61. allows you to add "special effects" like explanation windows that tell the
  62. viewer what you are doing, or that call up the narrator device to "speak"
  63. some information as your demonstration progresses.  
  64.  
  65. JOURNAL may not work with some programs the "take over" the system or
  66. bypass the Input.Device (see USAGE NOTES for additional information).
  67.  
  68.  
  69. HOW TO USE JOURNAL:
  70.  
  71. To run JOURNAL, type:
  72.  
  73.     1> RUN JOURNAL TO <file>
  74.  
  75. where <file> is the name of the journal file that you wish to produce.
  76. JOURNAL should respond by displaying its version number and telling you how
  77. to cancel it, and by moving the pointer to the upper, left-hand corner of
  78. the screen.  Once the pointer has been moved, JOURNAL will record all the
  79. key presses and mouse movements that you perform, by writing them to the
  80. file that you specified.
  81.  
  82. This file will be used A LOT, so if it is on floppy-disk, be sure that the
  83. disk can be left in the drive, and that it has enough space available for
  84. the journal file.  The journal grows FAST, so do some exparimenting before
  85. you create a long journal file.  RAM:  is a good place to write small
  86. journals, but may not be appropriate for long ones, as you may need your
  87. RAM space for the programs that you are running.
  88.  
  89. When you are done creating your journal, press CTRL-LEFTAMIGA-E.  This
  90. signals JOURNAL to stop recording events.  Once you get the "Joural
  91. Complete" message, any further actions will not be added to the journal
  92. file.
  93.  
  94.  
  95. HOW JOURNAL WORKS:
  96.  
  97. JOURNAL installs an input handler into the handler chain of the
  98. Input.Device.  This handler's priority puts it ahead of Intuition, so it
  99. sees the "undigested" events as they arrive from the Keyboard.Device,
  100. Gameport.Device, and Timer.Device.  When keyboard or mouse events are
  101. passed to the handler, it copies them into a linked list of events and
  102. signals JOURNAL that new events are ready, then passes the unmodified event
  103. list on to Intuition.
  104.  
  105. JOURNAL picks up the list of events and packs them into "TinyEvents" that
  106. take up fewer bytes, and records these in the output file.  To save even
  107. more space in the file, JOURNAL compresses multiple mouse move events into
  108. single output file records when possible, but records the number of events
  109. that were compressed, so that they can be recreated by PLAYBACK, if
  110. desired.  The amount of compression is controlled by command-line options
  111. (see below).
  112.  
  113. When the handler sees that CTRL-AMIGA-E has been pressed, it signals
  114. JOURNAL, which tells the Input.Device to remove the handler from the chain
  115. and closes the journal file.
  116.  
  117.  
  118. JOURNAL OPTIONS:
  119.  
  120. JOURNAL supports a number of command-line options that modify its behavior:
  121.  
  122. TO <file>     Designates <file> as the JOURNAL output file (the keyword
  123.                 "TO" is optional).
  124.  
  125. DX x            Specifies the amount of x movement that can be compressed
  126.         into one output event (mouse movements are added together
  127.         until their combined x-offsets exceed DX or their 
  128.         combined y-offsets exceed DY). The default value is 8.
  129.  
  130.     DY y            Specifies the amount of y movement that can be compressed
  131.                     into one output event (mouse movements are added together
  132.                     until their conbined x-offsets exceed DX or their
  133.                     combined y-offsets exceed DY).  The default value is 8.
  134.  
  135.     SMOOTHX x       Specifies an alternate value for DX that is used when 
  136.                 extra precision is needed (for example, when you need
  137.             to draw a free-form line in a paint program).  This 
  138.             value is in effect when the SMOOTH and TRIGGER mask 
  139.             conditions are met (see below).  The default value is 1.
  140.  
  141.     SMOOTHY y       Specifies an alternate value for DY that is used when
  142.                     extra precision is needed (for example, when you need
  143.                     to draw a free-form line in a paint program). This
  144.                     value is in effect when the SMOOTH and TRIGGER mask
  145.                     conditions are met (see below). The default value is 1.
  146.  
  147.     SMOOTH mask     Indicates which qualifier keys MUST be pressed in order
  148.                     to activate the SMOOTHX and SMOOTHY values.  Whan ALL
  149.                     the keys specified by the SMOOTH mask are pressed, and
  150.                     AT LEAST ONE of the keys designated by the TRIGGER mask
  151.                     is pressed, then the SMOOTHX and SMOOTHY values are
  152.                     used in place of DX and DY.  By default, the left Amiga
  153.                     key specifies smoothing.
  154.  
  155.     TRIGGER mask    Indicates which qualifier keys trigger the use of SMOOTHX
  156.                     and SMOOTHY.  When ANY ONE of the keys indicated by
  157.                     TRIGGER mask is pressed, and ALL of the keys specified
  158.                     by the SMOOTH mask are pressed, then SMOOTHX and
  159.                     SMOOTHY are used in place of DX and DY.  By default,
  160.                     any qualifier key triggers smoothing.
  161.  
  162. For people who understand "C" syntax, the expression that determines
  163. whether to use DX and DY or SMOOTHX and SMOOTHY is the following:
  164.  
  165.   if (((Qualifiers & SmoothMask) == SmoothMask) 
  166.        && (Qualifiers & TriggerMask))
  167.     use SMOOTHX and SMOOTHY
  168.    else
  169.     use DX and DY
  170.  
  171. Note that this provides considerable flexibility in specifying what will
  172. activate smoothing.  For example, to specify that pressing either button
  173. will cause smoothing, use:
  174.  
  175.     1> JOURNAL TO <file> SMOOTH 0 TRIGGER 0x6000
  176.  
  177. To specify that left Amiga plus left shift together with either button 
  178. should cause smoothing, use:
  179.  
  180.     1> JOURNAL TO <file> SMOOTH 0x0041 TRIGGER 0x6000
  181.  
  182. The complete set of qualifier values is listed in the include file 
  183. "DEVICES/INPUTEVENT.H".  Important values are listed here:
  184.  
  185.     Left Shift          0x0001
  186.     Right Shift         0x0002
  187.     Caps Lock           0x0004
  188.     Control             0x0008
  189.     Left ALT            0x0010
  190.     Right ALT           0x0020
  191.     Left Amiga          0x0040
  192.     Right Amiga         0x0080
  193.     Left Button         0x2000    
  194.     Right Button        0x4000
  195.  
  196. To determine the mask value, take the bitwise OR of the values for the
  197. qualifiers you want to use.  Note that the SMOOTH and TRIGGER masks should
  198. be specified in HEX, not decimal.
  199.  
  200.  
  201. HOW TO USE PLAYABCK:
  202.  
  203. To use playback, type:
  204.  
  205.     1> RUN PLAYBACK FROM <file>
  206.  
  207. where <file> is the name of a journal file recorded with the JOURNAL
  208. command.  PLAYBACK should print a message telling you its version number
  209. and how to abort the playback, and then should begin playing back the
  210. recorded events.  All you have to do is sit back and watch.  
  211.  
  212. When PLAYBACK is running, you will not be able to control the mouse
  213. yourself, and the keyboard will have no effect (except for CTRL-C, which
  214. cancels PLAYBACK). This is so that you do not disturb the sequence of the
  215. journal being played back.
  216.  
  217. When the last event is played back, PLAYBACK will inform you that it is
  218. done.
  219.  
  220. To cancel PLAYBACK at any time, press CTRL-C.  This is the only key that
  221. has any effect while PLAYBACK is running.
  222.  
  223.  
  224. HOW PLAYBACK WORKS:
  225.  
  226. PLAYBACK installs an input handler into the handler chain of the
  227. Input.Device.  This handler's priority puts it ahead of Intuition, so it
  228. can insert new events into or remove events from the stream seen by
  229. Intuition.  PLAYBACK reads packed events from the journal file and unpacks
  230. them into an event buffer where the input handler adds them to the event
  231. stream.
  232.  
  233. Since multiple
  234. mouse movements are compressed into single journal records, PLAYBACK must
  235. uncompress these by extrapolating intermediate mouse positions.  The input
  236. handler removes all keyboard and mouse events sent to it by the Input.Device
  237. so that these do not interfere with the journal being played back.  If the
  238. handler sees a CTRL-C it signals PLAYBACK that the user wants to abort the
  239. playback before it is complete.  PLAYBACK then requests the input.Device to
  240. remove the handler.
  241.  
  242. PLAYBACK uses a FIFO event queue to supply events to the input handler.
  243. Since the handler may have to wait for some time to pass before it posts
  244. the next event in the queue, this allows PLAYBACK to "read ahead" in the
  245. journal file, and prepare additional events for posting.  This makes the
  246. mouse movements smooth and un-interrupted.  When PLAYBACK fills the queue,
  247. it waits for the handler to post some events (freeing space in the queue).
  248. You can control the size of the queue via the EVENTS command-line option.
  249.  
  250.  
  251. PLAYBACK OPTIONS:
  252.  
  253. PLAYBACK supports a number of command-line options that modify its behavior:
  254.  
  255.     FROM <file>     Specifies the journal file to be played back (the keyword
  256.                     "FROM" is optional).
  257.  
  258.     EVENTS n     Specifies the size (in events) of the events buffer used to
  259.                     pass events from PLAYBACK to the input handler.  EVENTS
  260.                     must be at least two.  The default value is 50, but it
  261.                     can be set as low as 10 and still provide acceptable
  262.                     performance for some tasks.  The number of events may
  263.                     need to be increased if you have many other tasks
  264.                     running, or are accessing the disk containing the
  265.                     journal file frequently, or have specified small DX and
  266.                     DY values when you recorded the journal file.
  267.  
  268.     SMOOTH          Specifies that compressed mouse moves should be expanded
  269.                     into multiple mouse moves of smaller offsets.  This makes
  270.                     the playback look smoother, and makes precise mouse moves
  271.                     possible without taking up space in the journal file.
  272.                     The default is SMOOTH.
  273.  
  274.     NOSMOOTH        Specifies that compressed mouse moves should be left
  275.                     compressed (i.e., no extrapolated events should be
  276.                     posted). This may be necessary if you need extremely
  277.                     quick response time or if you have specified a small DX
  278.                     and DY during recording and do not need to uncompress
  279.                     mouse moves.  The default is SMOOTH.
  280.  
  281.  
  282. HOW TO COMPILE AND LINK JOURNAL AND PLAYBACK:
  283.  
  284. JOURNAL AND PLAYBACK were developed using the Lattice C compiler version
  285. 3.10. I have tried to make it as generic as possible, but since I don't
  286. have the Aztex C compiler, I don't know whether it works with Manx.  For
  287. Lattice C, all you have to do is:
  288.  
  289.     1> lc -v journal playback
  290.     1> asm handlerstub
  291.     1> blink with journal.lnk
  292.     1> blink with playback.lnk
  293.  
  294. The '-v' option is so that no stack checking code will be produced.  Since
  295. the input handler runs on the Input.Device's stack, this would confuse the
  296. stack check code and probably crash the system (I never tried it, though).
  297.  
  298.  
  299. USAGE NOTES:
  300.  
  301. Since PLAYBACK plays back exactly what was recorded by JOURNAL, it is
  302. important that the initial conditions be the same for both JOURNAL and
  303. PLAYBACK.  If even one window is not where it was when your ran JOURNAL,
  304. then PLAYBACK may become hopelessly out of synchronization.
  305.  
  306. It is best to run JOURNAL from a freshly booted system, or a newly opened
  307. NewCLI or AmigaDOS window.  If the journal needs programs or other windows
  308. to be open, don't open them first and then run JOURNAL.  Instead, run
  309. JOURNAL and then open the windows or run the programs.  This way you can be
  310. sure that what you want will be there, and in the proper places.  If you
  311. are recording actions on the Workbench, you should start with all the disk
  312. windows closed, and the disks in their default positions then open them
  313. within the journal.  Beware that disk positions may change depending on the
  314. order in which they were inserted.
  315.  
  316. One "feature" of JOURNAL and PLAYBACK is that they do not know about disk
  317. insert requesters.  If a disk requester comes up, JOURNAL keeps right on
  318. recording mouse moves and key strokes.  If you cancel the requester, so
  319. will PLAYBACK.  But if you put in a disk and the requester goes away, there
  320. is no guarantee that the user who is playing back your journal will replace
  321. the disk in the same amount of time you did (in fact, he may never replace
  322. it), so the rest of the journal may become out-of-synch.
  323.  
  324. Worse yet, the user can pop a disk out of the drive at any time, which may
  325. cause a disk requester to come up that did not appear when you recorded the
  326. journal, or the user might have fewer disk drives than you do, so he may
  327. have to swap drives differently from how you did.  All of these cases cause
  328. trouble for JOURNAL and PLAYBACK, so be careful when you are using multiple
  329. disks with journal. (See FUTURES for additional comments on
  330. disk-requesters).
  331.  
  332. Since JOURNAL will be writing lots of data to its output file, and PLAYBACK
  333. will be reading losts of data from the journal file, the journal file must
  334. be on a disk that can remain in a drive.  RAM:  is a good candidate for
  335. small journals, but may not have room for a large journal plus the programs
  336. that will be running.
  337.  
  338. JOURNAL's input handler allocates memory for the events as it copies them.
  339. This memory is not freed again until JOURNAL actually records the event.
  340. If events are coming in very fast, JOURNAL may not be able to keep up with
  341. them.  This may use up considerable memory until JOURNAL can catch up.  If
  342. you are having memory problems while using JOURNAL, try slowing down your
  343. mouse movements to give JOURNAL some time to catch up.
  344.  
  345. You may need to run JOURNAL and PLAYBACK at higher priorities than your
  346. normal processes in order to give them enough time to get the events to and
  347. from the input handler in a timely fashion.  Both progams use the Wait()
  348. function and neither "busy waits," so they should cooperate with other
  349. tasks even when they are at a higher priority.
  350.  
  351. If your journal runs a program that has to be loaded from disk, be sure to
  352. wait long enough for it to be loaded during the PLAYBACK.  Some disks take
  353. longer than others, and sometimes there are slight timing differences
  354. between JOURNAL and PLAYBACK.  Give a little extra time after disk accesses
  355. before you move the mouse or press a key.
  356.  
  357. JOURNAL only records mouse and keyboard events that come through the input
  358. device.  It does NOT record events that are received directly by a program
  359. through a message port from devices opened explicitly by the program.  For
  360. example, if your program opens the timer device and gets timer messages,
  361. these are NOT recorded by JOURNAL.  Similarly, JOURNAL does not record
  362. messages from the serial port, parallel port, or second mouse port.  Note
  363. that this means that JOURNAL will not record joystick motions from the
  364. second mouse port, so PLAYBACK can not reproduce them.  This may make it
  365. impossible to make a journal record of some games.
  366.  
  367.  
  368. FUTURES:
  369.  
  370. The disk insert problem mentioned in USAGE NOTES above needs to be fixed.
  371. The only solution I can think of is to use SetFunction to replace
  372. AutoRequest with a function that signals the JOURNAL or PLAYBACK process
  373. that a request has occured, then calls the original AutoRequest, then
  374. signals when the request is finished.  JOURNAL and PLAYBACK would "pause"
  375. until the AutoRequest was done, and then continue recording or playing
  376. back.  Since AutoRequest allows you to specify what kinds of flags will
  377. cancel the request, the replacement routine could check these to see if
  378. DISKINSERTED messages will satisfy it.  If not, then the original
  379. AutoRequest could be called without signalling the JOURNAL or PLAYBACK
  380. processes.  This way we would not be trapping the wrong requesters.
  381. Unfortunately, Workbench disk requests do not seem to use the DISKINSERTED
  382. flag, so something more sophsticated may be needed.  I am open to
  383. suggestions.
  384.  
  385. In the future (if there is enough interest), I plan to write a journal
  386. editor that allows you to step through a recorded journal and modify it by
  387. changing the events, adding new events, or deleting events.  Also, you will
  388. be able to add "special effects" like pop-up windows that contain
  389. explanations of what your program is doing, what qualifier keys are being
  390. pressed, etc.  I also hope to allow you to do this via the narrator device
  391. rather than through a window, if desired.  If I get real ambitious, I might
  392. even add something to play music from a file, but that will have to be far
  393. future for now.  If you want these features, please let me know.
  394.  
  395.  
  396. AUTHOR:
  397.  
  398. Davide P. Cervone
  399. University of Rochester Computing Center        DPVC@UORDBV.BITNET
  400. Taylor Hall                                     dpvc@tut.cc.rochester.EDU
  401. Rochester, New York  14627                      dpvc@ur-tut.UUCP
  402. (716) 275-2811
  403.  
  404.